package reflect;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import reflect.annotations.AutoRunClass;

import java.util.Scanner;

/**
 * 要求:程序启动后,控制台上任意一个类的完全限定名
 * 如果该类型被注解@AutoRunClass标注,则进行实例化,否则仅通知该类型没有被此注解标注
 * <p>
 * reflect.Person
 * 输出person的toString..
 * <p>
 * reflect.Student
 * Student类没有被注解标注!
 */
public class Test3 {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入类名:");
        String className = scan.nextLine();

        Class cls = Class.forName(className);
        if (cls.isAnnotationPresent(AutoRunClass.class)) {
            Object obj = cls.newInstance();
            System.out.println(obj);
        } else {
            System.out.println(cls.getName() + "类没有被注解标注");
        }
    }
}